#include<stdio.h>
int l(int n){
	return n/100;

}
int m(int n){
	int p=n/10%10;
	if(p) return 1;
	else  return 0;
}
int o(int n){
	int p=n%10;
	if(p) return 1;
	else  return 0;
}
int main()
{
	int sum=0;
	for(int i=123;i<=987;i++){
		for(int j=123;j<=987;j++){
			for(int k=123;k<=987;k++){
				if(l(i)&&m(i)&&o(i)&&l(j)&&m(j)&&o(j)&&l(k)&&m(k)&&o(k)) continue;
				if(l(i)!=m(i)!=o(i)!=l(j)!=m(j)!=o(j)!=l(k)!=m(k)!=o(k)&&i+j==k)
					sum++;
			}
		}
	}
	printf("%d",sum); 
	return 0;
}
